package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.ListNode;

/**
 * 1290. 二进制链表转整数
 * 
 * https://leetcode.cn/problems/convert-binary-number-in-a-linked-list-to-integer/
 * 
 * @author jie.deng
 *
 */
class Question1290Solution01 {
	
	public int getDecimalValue(ListNode head) {
		int num = 0;
		ListNode cur = head;
		while (cur != null) {
			num <<= 1;
			num += cur.val;
			cur = cur.next;
		}
		return num;
	}
    
}